<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">配置名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入车辆名称" value="" class="layui-input">
                <tip>配置的名称，用做维护人员标识。</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">配置Key</label>
            <div class="layui-input-block">
                <input type="text" name="configKey" lay-verify="required" lay-reqtext="价格不能为空" placeholder="请输入价格" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">配置value</label>
            <div class="layui-input-block">
                <input type="text" name="configValue" lay-verify="required" lay-reqtext="价格不能为空" placeholder="请输入价格" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            upload = layui.upload,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */

        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                type: "POST",
                url: "configInfo/save",//发送请求
                data: data.field,
                // contentType:"application/json;charset=utf-8",
                success: function (result) {
                    if (result.code == 0){
                        layer.msg(result.msg)
                    }else {
                        layer.msg(result.msg)
                    }
                },
                error: function (err) {
                    console.error(err)
                },
                complete: function (res) {
                    // 关闭弹出层
                    // layer.close(index);
                    layer.close(parentIndex);
                }
            })
            return false;
        });



    });
</script>
